#!/bin/bash

result1=$(ps -ef | grep 'nginx: master process nginx' | grep -v grep) #监测本机nginx是否可用
if [[ -z $result1 ]]; then #判断是否需要转换
  echo $(date) "nginx not print coordinator:true sleep 2,retry" > /data/br/logs/keepalive.log #记录转换日志
  sleep 2
  result2=$(ps -ef | grep 'nginx: master process nginx' | grep -v grep) #再次监测本机presto是否可用
  if [[ -z $result2 ]]; then #判断是否需要转换
    echo $(date) "nginx is not health, kill keepalive"  > /data/br/logs/keepalive.log
    pkill keepalived
  fi
fi
